<?php
define('FPDF_FONTPATH','font/');
require('../FPDF/fpdf.php');
include("../includes/conexion.php");
include("../includes/funciones.php");

$pdf=new FPDF('P','cm','A4');
$pdf->Open();
$pdf->AddPage();
$pdf->SetFont('Arial','B',8);


$registro_usuarios = traerDatosUsuarios($_GET['id_usuarios']);
$registro_usuarios = explode("|",$registro_usuarios);

$cod_matricula = $registro_usuarios[3];
$nombres = utf8_decode($registro_usuarios[4]);
$ape_pate = utf8_decode($registro_usuarios[5]);
$ape_mate = utf8_decode($registro_usuarios[6]);

$fecha_ini = $registro_usuarios[13];
$fecha_fin = $registro_usuarios[14];

$foto = trim($registro_usuarios[12]);

$id_especialidad = $registro_usuarios[15]; 

$tipo_usuario = $registro_usuarios[17];

//-------------------------------------------Delante ------------------------------------------------------------------------

$pdf->Image("../images/escudo_unas.jpg", 1, 1,1.8,2.1);
$pdf->Cell(8,5,"",1,0,'C');  // Matricula

$pdf->SetXY(3.1,1.1);
$pdf->SetFont('Arial','BI',6.8);
$pdf->SetTextColor(60,179,113 );
$pdf->Cell(5.7,0.5,"UNIVERSIDAD NACIONAL AGRARIA DE LA SELVA",0,0,'C');
$pdf->SetLeftMargin(3.1);
$pdf->ln();
$pdf->SetTextColor(0,0,255);
$pdf->Cell(5.7,0.5,"OFICINA DE BIBLIOTECA CENTRAL",0,0,'C');
$pdf->ln();
$pdf->SetTextColor(255,0,0);
$pdf->Cell(5.7,0.5,"CARNET DE LECTOR",0,0,'C');

$pdf->SetLeftMargin(1);

$pdf->ln(); $pdf->ln();

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(255,0,0);
$pdf->Cell(1.2,0.4,"Lector",0,0,'L');
$pdf->Cell(0.1,0.4,":",0,0,'C');
$pdf->SetTextColor(0,0,255);
$pdf->Cell(2,0.4,strtoupper($tipo_usuario),0,0,'L');
$pdf->ln();
$pdf->SetTextColor(255,0,0);
$pdf->Cell(1.2,0.4,"Ape. Pat.",0,0,'L');
$pdf->Cell(0.1,0.4,":",0,0,'C');
$pdf->SetTextColor(0,0,255);
$pdf->Cell(2,0.4,$ape_pate,0,0,'L');
$pdf->ln();
$pdf->SetTextColor(255,0,0);
$pdf->Cell(1.2,0.4,"Ape. Mat.",0,0,'L');
$pdf->Cell(0.1,0.4,":",0,0,'C');
$pdf->SetTextColor(0,0,255);
$pdf->Cell(2,0.4,$ape_mate,0,0,'L');
$pdf->ln();
$pdf->SetTextColor(255,0,0);
$pdf->Cell(1.2,0.4,"Nombres.",0,0,'L');
$pdf->Cell(0.1,0.4,":",0,0,'C');
$pdf->SetTextColor(0,0,255);
$pdf->Cell(2,0.4,$nombres,0,0,'L');
$pdf->ln();
$pdf->SetTextColor(255,0,0);
$pdf->Cell(1.2,0.4,"Cod. Mat.",0,0,'L');
$pdf->Cell(0.1,0.4,":",0,0,'C');
$pdf->SetTextColor(0,0,255);
$pdf->Cell(2,0.4,$cod_matricula,0,0,'L');
$pdf->ln();
$pdf->SetTextColor(255,0,0);

if(strtoupper($tipo_usuario)=="DOCENTE"){
	$pdf->Cell(1.2,0.3,"Facul.",0,0,'L');
	$pdf->Cell(0.1,0.3,":",0,0,'C');
	$pdf->SetTextColor(0,0,255);
	$pdf->Cell(2,0.4,strtoupper(traer_facultada($id_especialidad)),0,0,'L');
}else{
	$pdf->Cell(1.2,0.3,"Espec.",0,0,'L');
	$pdf->Cell(0.1,0.3,":",0,0,'C');
	$pdf->SetTextColor(0,0,255);
	$pdf->Cell(2,0.4,strtoupper(retorana_descr_especia($id_especialidad)),0,0,'L');
}


$pdf->ln();
$pdf->Cell(8,0.2,"",0,0,'C');
$pdf->ln();
$pdf->Cell(8,0.2,"",0,0,'C');
$pdf->ln();
$pdf->Cell(8,0.2,"",0,0,'C');
$pdf->ln();$pdf->ln();$pdf->ln();
$pdf->Image("../../FancyUpload/files/$foto", 6.5,2.8,2.2,2.7);

//-------------------------------------------Atras ------------------------------------------------------------------------
$pdf->SetY(1);
$pdf->SetLeftMargin(9.1);
$pdf->Cell(8,5,"",1,0,'C');  // Matricula
$pdf->SetFont('Arial','B',7);
$pdf->SetTextColor(60,179,113 );
$pdf->SetXY(10,1.1);
$pdf->Cell(8,0.5,"ORIGINAL Y/O DUPLICADO",0,0,'C');
$pdf->SetTextColor(255,0,0);
$pdf->SetLeftMargin(9.2);
$pdf->ln();
$pdf->Cell(8,0.3,"Este documento es �nico y personal, para solicitar los servicios",0,0,'L');
$pdf->ln();
$pdf->Cell(8,0.3,"bibliotecarios. En caso de extravio devolverlo a esta",0,0,'L');
$pdf->ln();
$pdf->Cell(8,0.3,"Dependencia",0,0,'L');
$pdf->ln();$pdf->ln();$pdf->ln();
$pdf->SetLeftMargin(10.1);
$pdf->Cell(2.5,0.3,"Fecha de Emisi�n ",0,0,'L');
$pdf->Cell(0.5,0.3,":",0,0,'c');
$pdf->Cell(2.5,0.3,$fecha_ini,0,0,'L');
$pdf->ln();$pdf->ln();
$pdf->Cell(2.5,0.3,"Valido hasta el",0,0,'L');
$pdf->Cell(0.5,0.3,":",0,0,'c');
$pdf->Cell(2.5,0.3,$fecha_fin,0,0,'L');

$pdf->SetTextColor(0,0,255);
$pdf->SetLeftMargin(12.1);
$pdf->ln();$pdf->ln();$pdf->ln();$pdf->ln();
$pdf->Cell(2.8,0.3,"",'B',0,'L');$pdf->ln();
$pdf->Cell(2.8,0.3,"Direcci�n - OBC",0,0,'C');
//$pdf->Output();
$pdf->Output("carnets.pdf","F");


function retorana_descr_especia($id_especialidad){
    $sql="select * from especialidad where id_especialidad = '$id_especialidad' ";
	$result = mysql_query($sql);
	$row=mysql_fetch_array($result);   
	return $row['des_especialidad'];
}


?>